﻿using System;
using System.Windows.Shapes;

namespace Bookvar.UI
{
    public abstract class ConnectingShapeTopicConnector : ShapeTopicConnector
    {
        protected abstract ConnectingShape ConstructConnectingShape();

        protected override Shape GetShape( TopicContentPresenter parent, TopicContentPresenter child )
        {
            ConnectingShape shape = ConstructConnectingShape();

            if ( parent.Topic.IsMainTopic )
            {
                shape.SetBinding( ConnectingShape.StartPointProperty, BindingHelper.CreateControlCenterBinding( parent ) );
            }
            else
            {
                shape.SetBinding( ConnectingShape.StartPointProperty, BindingHelper.CreateToggleButtonBinding( parent ) );
            }
            shape.SetBinding( ConnectingShape.EndPointProperty, BindingHelper.CreateControlCenterBinding( child ) );

            return shape;
        }
    }
}
